#ifndef GOOGLE_READER_HPP
#define GOOGLE_READER_HPP

/****************************************************
*       Forward declaration
****************************************************/
template <class Key, class T>
class QMap;
class QBuffer;
class QIODevice;

/****************************************************
*       QT dependencies
****************************************************/
#include <QObject>
#include <QString>

/****************************************************
*       Internal dependencies
****************************************************/
#include "web_client.hpp"


class Result : public QObject
{
Q_OBJECT;
public:
    Result();
    virtual ~Result();
    int status;
};


/****************************************************
*       GoogleReaderFeed class declatation
****************************************************/
/*
class GoogleReaderFeed : public Result
{
Q_OBJECT;
public:
    GoogleReaderFeed();
    GoogleReaderFeed(QString xmlData);
};
*/

/****************************************************
*       GoogleReader class declatation
****************************************************/
class GoogleReader : public QObject
{
Q_OBJECT;
private:
    WebClient* _webClient;
    QString _username;
    QString _password;
    QMap<QString, QBuffer*> *_buffers;
    QMap<QString, Result*> *_results;

    int _parseLogin(QIODevice *data);

public:
    GoogleReader(QString username="", QString password="",
                 WebClient::SynchronizationMode mode=WebClient::Asynchronous);
    virtual ~GoogleReader();
    int login();
    int login(QString username, QString password);
    int getSubscriptionList();

private:
    static QString ROOT_URL;
    static QString LOGIN_URL;
    static QString SOURCE;
public slots:
    void httpRequestFinished(QString url, int status, QIODevice* data);

signals:

    void loginFinished(int status);
};

#endif // GOOGLE_READER_HPP
